package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.ClassBean;
import com.project.mapper.IClassMapper;
import com.project.service.IClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author lyl
 * description:班级业务接口实现类
 */
@Service
@Transactional
public class ClassServiceImpl implements IClassService {
    @Autowired
    private IClassMapper iClassMapper;

    @Override
    public PageInfo<ClassBean> findAllByPage(int PageNo) {
        PageHelper.startPage(PageNo, 3);
        PageInfo<ClassBean> pageInfo = PageInfo.of(iClassMapper.findAllByPage());
        return pageInfo;
    }

    @Override
    public void add(ClassBean classBean) {
        iClassMapper.add(classBean);
    }

    @Override
    public void updateClassTeacher(int classId, String teacherName) {
        iClassMapper.updateClassTeacher(classId, teacherName);
    }

    @Override
    public ClassBean findById(int classId) {
        return iClassMapper.findById(classId);
    }

    @Override
    public void del(int classId) {
        iClassMapper.del(classId);
    }
}
